package connect.bdd;

import java.sql.*;

public class BDDModif extends BDDConnect {

    ResultSet res;
    Statement stmt;

    public BDDModif(String drivers, String url, String user, String pass) {
        super(drivers, url, user, pass);


    }

    public boolean envoiReq(String req) {
        try {
            this.stmt = this.con.createStatement();
            this.res = this.stmt.executeQuery(req);
        } catch (SQLException ex) {
            System.err.println("==>SQL Exception :\n");
            while (ex != null) {
                System.out.println("Message: " + ex.getMessage());
                System.out.println("SQLState: " + ex.getSQLState());
                System.out.println("ErrorCode: " + ex.getErrorCode());
                ex = ex.getNextException();
                System.out.println("");
                return false;
            }
        }
        return true;

    }

    public boolean envoiReqUpdate(String requ) {
        try {
            this.stmt = this.con.createStatement();
            int x = this.stmt.executeUpdate(requ);
            System.out.println("Nombre de modifications apportees:" + x);
        } catch (SQLException e) {
            System.err.println("==>SQL Exception :\n");
            while (e != null) {
                System.out.println("Message: " + e.getMessage());
                System.out.println("SQLState: " + e.getSQLState());
                System.out.println("ErrorCode: " + e.getErrorCode());
                e = e.getNextException();
                System.out.println("");
                return false;
            }
        }
        return true;
    }
}
